@/*
表单中时间输入框标签中各个参数的说明:

id : input框id
name : input框名称
readonly : readonly属性
style : 附加的css属性
disabled : 禁用
dateRange:是否开始时间范围
dateType:时间类型（格式）
@*/


<div class="form-group">
    @if(isNotEmpty(name)){
    <label class="col-sm-3 control-label">
        @if(isNotEmpty(required)&&required!=false){
        *
        @}
        ${name}</label>
    @}
    @if(isEmpty(dateRange)){
    <div class="col-sm-9">
        <input class="form-control" id="${id}" name="${id}"  type="text" readonly="readonly"
               @if(isNotEmpty(style)){
               style="${style}"
               @}else if(isEmpty(disabled)){
               style="background-color: #ffffff;"
               @}
               @if(isNotEmpty(disabled)){
               disabled="${disabled}"
               @}
        />
    </div>
    @}else{
    <div class="col-sm-4">
        <input class="form-control" id="start_${id}" name="start_${id}"  type="text" placeholder="开始时间"
               readonly="readonly"
               @if(isNotEmpty(style)){
               style="${style}"
               @}else if(isEmpty(disabled)){
               style="background-color: #ffffff"
               @}
               @if(isNotEmpty(disabled)){
               disabled="${disabled}"
               @}
        />
    </div>
    <div class="col-sm-1"><i class="fa fa-minus  center-block"></i></div>
    <div class="col-sm-4">
        <input class="form-control" id="end_${id}" name="end_${id}"  type="text" placeholder="结束时间"
               readonly="readonly"
               @if(isNotEmpty(style)){
               style="${style}"
               @}else if(isEmpty(disabled)){
               style="background-color: #ffffff;"
               @}
               @if(isNotEmpty(disabled)){
               disabled="${disabled}"
               @}
        />
    </div>
    @}
</div>
@if(isNotEmpty(underline) && underline == 'true'){
<div class="hr-line-dashed"></div>
@}

<script>
    @if(isEmpty(dateRange)){
        laydate.render({
            elem: '#${id}'
            ,value:"${date.format(value!,pattern!)}"
            @if (isNotEmpty(dateType)) {
                ,type:'${dateType}'
            @}
            @if (isNotEmpty(pattern)) {
                , format: '${pattern}'
            @}
            ,done: function (value, date, endDate) {
                $("#${id}").val(value).change();
            }
        });
    @}else{
        var layerStart${id}= laydate.render({
            elem: '#start_${id}'
            @if(isNotEmpty(end)){
                ,max: "${date.format(end!,pattern!)}"
             @}
            ,value:"${date.format(start!,pattern!)}"
            @if (isNotEmpty(dateType)) {
            ,type:'${dateType}'
            @}
            @if (isNotEmpty(pattern)) {
            ,format: '${pattern}'
            @}
            ,done: function (value, date, endDate) {
                $("#start_${id}").val(value).change();
                if(value==""){
                    layerEnd${id}.config.min={
                        year:1900,
                        month:0,
                        date:1
                    };
                }else{
                    layerEnd${id}.config.min={
                        year:date.year,
                        month:date.month-1,//关键
                        date: date.date,
                        hours: date.hours,
                        minutes: date.minutes,
                        seconds : date.seconds
                    }
                }
            }
         });
        var layerEnd${id} = laydate.render({
            elem: '#end_${id}'
            @if(isNotEmpty(start)){
                ,min: "${date.format(start!,pattern!)}"
             @}
            ,value:"${date.format(end!,pattern!)}"
            @if (isNotEmpty(dateType)) {
            ,type:'${dateType}'
            @}
            @if (isNotEmpty(pattern)) {
            , format: '${pattern}'
            @}
            ,done: function (value, date, endDate) {
                $("#end_${id}").val(value).change();
                if(value==""){
                    layerStart${id}.config.max={
                        year:2099,
                        month:11,
                        date:31
                    };
                }else{
                    layerStart${id}.config.max={
                        year:date.year,
                        month:date.month-1,//关键
                        date: date.date,
                        hours: date.hours,
                        minutes: date.minutes,
                        seconds : date.seconds
                    }
                }
        }
        });
    @}
</script>



